<template>
  <div class="info-rdb-root info-root">
    <div class="info-title">
      RDB备份信息
    </div>
    <div class="info-content">
      <el-descriptions class="qa-gw-desc" :column="2">
        <el-descriptions-item label="上次创建结果:">
          <el-tag type="info">{{ redisInfo.rdb_last_bgsave_status }}</el-tag>
        </el-descriptions-item>
        <el-descriptions-item label="上次创建用时:">
          <el-tag type="info">{{ redisInfo.rdb_last_bgsave_time_sec }}</el-tag>
        </el-descriptions-item>
        <el-descriptions-item label="上次创建大小:" :span="2">
          <el-tag type="info">{{ redisInfo.rdb_last_cow_size }}</el-tag>
        </el-descriptions-item>
        <el-descriptions-item label="上次创建时间:" :span="2">
          <el-tag type="info">{{ secondsFormat(redisInfo.rdb_last_save_time) }}</el-tag>
        </el-descriptions-item>
      </el-descriptions>
    </div>
  </div>
</template>

<script setup lang="ts">
import { ref } from "vue";
import { secondsToDatetime } from "@/assets/utils/util";

const redisInfo = ref({
  rdb_last_bgsave_status: "",
  rdb_last_bgsave_time_sec: 0,
  rdb_last_cow_size: 0,
  rdb_last_save_time: 0
})

const initMap = (info: any) => {
  redisInfo.value = info;
}

const secondsFormat = (s: number): string => {
  return secondsToDatetime(s);
}

defineExpose({
  initMap
})
</script>

<style scoped lang="scss">
.info-rdb-root {
  @include box(100%, 100%);

  .info-title {
    @include themeColor(#AE564C, #aa4d45)
  }
}
</style>